/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Ashe Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2020/1/8 12:40 上午
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.capsule.spring.boot.hello.config;

import com.capsule.spring.boot.hello.annotation.ConditionOnSystem;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author Ashe
 * @version V1.0.0
 * @date 2020/1/8 12:40 上午
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人}  2020/1/8
 * @modify reason: {方法名}:{原因}
 * ...
 */
public class OnSystemCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Map<String, Object> metaDataMap = metadata.getAnnotationAttributes(ConditionOnSystem.class.getName());
        return "windows".equals(metaDataMap.get("system"));
    }

}
